﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SQLTouch.Service.DataContracts;
using SQLTouch.Service.Implementation.DAL;
using SQLTouch.Service.ServiceContracts;

namespace SQLTouch.Service.Implementation
{
    public class TouchService : ITouchService
    {
        private readonly ISchemaDAL schemaDAL;
        private readonly ISliceDAL sliceDAL;

        public TouchService()
            : this(new SchemaDAL(), new SliceDAL())
        {

        }

        public TouchService(ISchemaDAL schemaDAL, ISliceDAL sliceDAL)
        {
            this.schemaDAL = schemaDAL;
            this.sliceDAL = sliceDAL;
        }

        public SchemaData GetSchema(string connectionString)
        {
            return schemaDAL.GetSchema(connectionString);
        }

        private QueryResultData GetFakeSlice()
        {
            return new QueryResultData(new List<QueryResultColumnData>()
            {
                new QueryResultColumnData<float>("floats", new List<float>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }),
                new QueryResultColumnData<int>("ints", new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }),
                new QueryResultColumnData<string>("strings", new List<string>() { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" }),
                new QueryResultColumnData<int>("count", new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }),
            });
        }

        public QueryResultData GetQueryResult(string connectionString, QueryData query)
        {
            return sliceDAL.GetSlice(connectionString, query);
        }
    }
}
